VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsServices"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

' Services control module

Dim WithEvents IRC As clsModIRC
Attribute IRC.VB_VarHelpID = -1
Dim PassCount As Integer
Dim justActivated As Boolean

Public lastPass As String
Public nsIdentified As Boolean

Sub Associate(ByRef Rf As clsModIRC)
Set IRC = Rf
DebugMe "SERV: Link to IRC control associated!"
PassCount = 0
End Sub

Private Sub DebugMe(ByVal ST As String)
If modAC.WriteDebugs = True Then Print #3, ST Else _
  Debug.Print ST
End Sub

Private Sub Class_Initialize()
DebugMe "SERV: Loaded services control module"
End Sub

Private Sub IRC_Generic(ByVal Command As String, ByVal Data As String, ByVal Comment As String)
Select Case Command
  Case "304"
 
    If InStr(Data, "Password accepted") > 0 Then
      PassCount = 0
      nsIdentified = True
      frmMain.SpeechInterface.Say "Your nickname password was accepted!"
    End If
End Select
End Sub

Private Sub IRC_Notice(ByVal Text As String, ByVal Nick As String, ByVal mask As String, ByVal Dest As String)
Select Case LCase(Nick)

' NickServ properties
  Case "nickserv"
  
    If InStr(Text, "This nick is owned by someone else") > 0 Then
      ' Get identify password
      PassCount = PassCount + 1
      identifyNickname
    ElseIf InStr(Text, "Password incorrect.") > 0 Then
      ' Get identify password
      PassCount = PassCount + 1
      If PassCount = 4 Then
        MsgBox "Password incorrect! You are now being disconnected from Nightowl. Please try a different nickname.", vbOKOnly + vbCritical, "Incorrect password"
      Else
        MsgBox "The nickname password you entered was not correct! You have " & GetWord(Text, 5) & " more chances to enter it correctly.", vbOKOnly + vbCritical, "Incorrect Password"
        identifyNickname True
      End If
    ElseIf InStr(Text, "Password accepted") > 0 Then
      PassCount = 0
      frmMain.SpeechInterface.Say "Your nickname password was accepted!"
      nsIdentified = True
      If justActivated = True Then
        IRC.SendMessage "NickServ", "ACCESS DEL 1"
        IRC.SendMessage "NickServ", "SET SECURE ON"
        justActivated = False
      End If
    End If
   
End Select

End Sub

Private Sub identifyNickname(Optional dontUseAuto As Boolean)
Dim gotNick As Boolean
Dim np As String
Dim nstp As String

Do Until gotNick = True
  np = InputBox("The nickname you've chosen is owned by somebody else. If this nickname is yours, input your password; otherwise, please close Nightowl and choose a new nickname.", "Nickname Identification")
  If np = "" Then
    nstp = MsgBox("You didn't provide a nickname password. You must provide the proper password to use this nickname. Would you like to enter a password? Choose No to enter a different nickname.", vbYesNo Or vbQuestion, "Nickname Identification")
    If nstp = vbNo Then
      ' change nickname temporarily
      Randomize Timer
      IRC.RawSend "NICK Unidentified" & CStr(Int(Rnd * 65536) + 1)
      Load frmNick
      frmNick.FormMode = 3
      frmNick.Show vbModal, frmMain
      Exit Sub
    End If
  Else
    gotNick = True
  End If
Loop

  IRC.SendMessage "NickServ", "identify " & np
  lastPass = np
End Sub
 
